
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module main</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>main</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/karki/cs373-project2/main.py">/Users/karki/cs373-project2/main.py</a></font></td></tr></table>
    <p><tt>#&nbsp;-------------------------------<br>
#&nbsp;projects/python/primes/main.py<br>
#&nbsp;Copyright&nbsp;(C)&nbsp;2009<br>
#&nbsp;Glenn&nbsp;P.&nbsp;Downing<br>
#&nbsp;-------------------------------</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="main.html#InputReader">InputReader</a>
</font></dt><dt><font face="helvetica, arial"><a href="main.html#OutputWriter">OutputWriter</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="InputReader">class <strong>InputReader</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="InputReader-read"><strong>read</strong></a>(self)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="OutputWriter">class <strong>OutputWriter</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="OutputWriter-write"><strong>write</strong></a>(self, *a)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-false_print"><strong>false_print</strong></a>(w)</dt><dd><tt>writes&nbsp;"Impossible."&nbsp;This&nbsp;statement&nbsp;occurs&nbsp;when&nbsp;a&nbsp;number&nbsp;cannot&nbsp;be&nbsp;written&nbsp;as&nbsp;the&nbsp;sum&nbsp;of&nbsp;4&nbsp;prime&nbsp;numbers</tt></dd></dl>
 <dl><dt><a name="-isPrime"><strong>isPrime</strong></a>(n)</dt><dd><tt>checks&nbsp;to&nbsp;see&nbsp;if&nbsp;n&nbsp;is&nbsp;a&nbsp;prime&nbsp;number<br>
returns&nbsp;true&nbsp;if&nbsp;n&nbsp;is&nbsp;prime,&nbsp;false&nbsp;otherwise<br>
&nbsp;<br>
This&nbsp;method&nbsp;was&nbsp;borrowed&nbsp;from&nbsp;the&nbsp;textbook,&nbsp;<br>
"Data&nbsp;Structures&nbsp;and&nbsp;Problem&nbsp;Solving&nbsp;Using&nbsp;Java"&nbsp;by&nbsp;Mark&nbsp;Allen&nbsp;Weiss&nbsp;(p.358).&nbsp;&nbsp;I&nbsp;modified&nbsp;it&nbsp;to&nbsp;work&nbsp;in&nbsp;Python&nbsp;and&nbsp;added&nbsp;some&nbsp;additional&nbsp;if-<br>
statements&nbsp;to&nbsp;return&nbsp;false&nbsp;if&nbsp;n&nbsp;&lt;=&nbsp;1&nbsp;or&nbsp;if&nbsp;n&nbsp;is&nbsp;an&nbsp;even&nbsp;number,&nbsp;and&nbsp;another&nbsp;one&nbsp;to&nbsp;return&nbsp;true&nbsp;if&nbsp;n&nbsp;==&nbsp;2.<br>
If&nbsp;n&nbsp;is&nbsp;odd&nbsp;and&nbsp;n&nbsp;&gt;=&nbsp;3,&nbsp;the&nbsp;method&nbsp;uses&nbsp;trial&nbsp;division&nbsp;to&nbsp;test&nbsp;if&nbsp;the&nbsp;number&nbsp;is&nbsp;prime.&nbsp;&nbsp;n&nbsp;is&nbsp;prime&nbsp;if<br>
it&nbsp;is&nbsp;not&nbsp;divisible&nbsp;by&nbsp;any&nbsp;other&nbsp;odd&nbsp;number&nbsp;&lt;=&nbsp;the&nbsp;square&nbsp;root&nbsp;of&nbsp;n&nbsp;(p.357).</tt></dd></dl>
 <dl><dt><a name="-main"><strong>main</strong></a>()</dt><dd><tt>runs&nbsp;the&nbsp;program</tt></dd></dl>
 <dl><dt><a name="-my_eval"><strong>my_eval</strong></a>()</dt><dd><tt>checks&nbsp;to&nbsp;see&nbsp;if&nbsp;x&nbsp;can&nbsp;be&nbsp;written&nbsp;as&nbsp;the&nbsp;sum&nbsp;of&nbsp;4&nbsp;prime&nbsp;numbers<br>
returns&nbsp;true&nbsp;if&nbsp;it&nbsp;can,&nbsp;and&nbsp;stores&nbsp;the&nbsp;4&nbsp;values&nbsp;in&nbsp;num1,&nbsp;num2,&nbsp;num3,&nbsp;and&nbsp;num4<br>
returns&nbsp;false&nbsp;if&nbsp;x&nbsp;cannot&nbsp;be&nbsp;written&nbsp;as&nbsp;the&nbsp;sum&nbsp;of&nbsp;4&nbsp;primes</tt></dd></dl>
 <dl><dt><a name="-my_print"><strong>my_print</strong></a>(w)</dt><dd><tt>writes&nbsp;the&nbsp;values&nbsp;of&nbsp;num1,&nbsp;num2,&nbsp;num3,&nbsp;and&nbsp;num4</tt></dd></dl>
 <dl><dt><a name="-my_read"><strong>my_read</strong></a>(r)</dt><dd><tt>reads&nbsp;an&nbsp;int&nbsp;into&nbsp;x<br>
return&nbsp;true&nbsp;if&nbsp;that&nbsp;succeeds,&nbsp;false&nbsp;otherwise</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>num1</strong> = 0<br>
<strong>num2</strong> = 0<br>
<strong>num3</strong> = 0<br>
<strong>num4</strong> = 0<br>
<strong>x</strong> = 0</td></tr></table>
</body></html>